<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input v-model="params.message"   placeholder="内容" style="width: 200px;" class="filter-item" @keyup.enter.native="fetchData" clearable/>
      <el-input v-model="params.ip"   placeholder="操作IP" style="width: 200px;margin-left: 10px;" class="filter-item" @keyup.enter.native="fetchData" clearable/>
      <el-input v-model="params.createUser"   placeholder="操作用户" style="width: 200px;margin-left: 10px;" class="filter-item" @keyup.enter.native="fetchData" clearable/>
      <el-button v-waves class="filter-item"   type="primary" icon="el-icon-search" @click="fetchData" style="margin-left: 10px;">
        搜索
      </el-button>
      <el-button @click="resetForm()" type="success" icon="el-icon-warning-outline" class="filter-item">重置</el-button>
    </div>

    <el-table
      v-loading="listLoading"
      :data="list"

      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column label="内容">
        <template slot-scope="scope">
          {{ scope.row.message }}
        </template>
      </el-table-column>
      <el-table-column label="操作IP" align="center">
        <template slot-scope="scope">
          {{ scope.row.ip }}
        </template>
      </el-table-column>
      <el-table-column label="操作用户" align="center">
        <template slot-scope="scope">
          {{ scope.row.createUser }}
        </template>
      </el-table-column>
      <el-table-column label="操作时间" align="center">
        <template slot-scope="scope">
          {{ scope.row.createTime }}
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="params.page" :limit.sync="params.pageSize" @pagination="fetchData" />

  </div>
</template>

<script>
import { get } from '@/utils/request'
import Pagination from '@/components/Pagination'
import waves from '@/directive/waves'

export default {
  components: { Pagination },
  directives: { waves },
  data() {
    return {
      list: null,
      listLoading: true,
      total: 10,
      params: {
        page: 1,
        pageSize: 10,
      }
    }
  },
  created() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      this.listLoading = true
      get("/sysUser/adminLogList.json",this.params).then(response => {
        this.total=response.total
        this.list = response.rows
        this.listLoading = false
      })
    },
    resetForm(){
      this.params={
        page:1,
        pageSize:10
      }
      this.$nextTick(()=>{
        this.fetchData();
      })
    }
  }
}
</script>
